<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <button id="send">发送请求</button>
  <script src="https://cdn.bootcdn.net/ajax/libs/qs/6.11.2/qs.min.js"></script>
  <script>
    var qs = Qs;
    let info = {
      name: '廖'
    }
    let btn = document.getElementById("send")

    //创建异步对象
    let xhr = new XMLHttpRequest()
    myAjax = function () {


      xhr.open('get', 'http://127.0.0.1:7001/getUserInfo' + "?" + qs.stringify(info))

      xhr.setRequestHeader('Content-Type', 'application/json')

      xhr.send()

      xhr.onreadystatechange = function () {
        if (xhr.readyState == 4 && xhr.status == 200) {
          let res = xhr.responseText
          console.log(res);
        }
      }
    }
    btn.addEventListener('click', myAjax)

  </script>
</body>

</html>